limsEquipment.editPage = {

    getGridParam: function () {
        var _this = this
        return {
            type: 'grid',
            id: _this.idManager.equipGrid,
            url: limsEquipment.baseUrl + '/queries',
            service: 'limsEquipmentServiceImpl',
            dbTable: 'T_LIMS_EQUIPMENT',
            columns: limsEquipment.getEditListColumns(),
            onLoadSuccess: function (data) {
                if (!Gikam.isEmpty(data)) {
                    this.activeRowByIndex(0)
                } else {
                    _this.refreshTabs(null)
                }
            },
            deleteFormatter: function (row) {
                return row.equipCode || row.id
            },
            onRowActive: function (index, row) {
                _this.refreshTabs(row)
            },
            onCellClick: function (field, row) {
                field === 'equipCode' && _this.loadDetailPage(row);
            },
            page: true,
            toolbar: [{
                type: 'button',
                text: 'GIKAM.BUTTON.INSERT',
                icon: 'add',
                onClick: function () {
                    Gikam.preInsert({
                        modalTitle: 'BASEMODULE.RM.EQUIPMENTS.MODAL.ADD',
                        fields: limsEquipment.getBaseInfoFormFields(),
                        url: limsEquipment.baseUrl
                    }).done(function (id) {
                        _this.loadDetailPage({id:id})
                        Gikam.getComp(_this.idManager.equipGrid).refresh()
                    })
                }
            }, {
                type: 'button',
                text: 'GIKAM.BUTTON.DELETE',
                icon: 'remove-row',
                onClick: function () {
                    Gikam.getComp(_this.idManager.equipGrid).deleteRows(limsEquipment.baseUrl)
                }
            }, {
                type: 'button',
                text: 'GIKAM.BUTTON.IMPORT',
                icon: 'upload',
                onClick: function () {
                    Gikam.create('simpleUploader', {
                        id: 'equipment-uploader',
                        dbTable: 'T_LIMS_EQUIPMENT',
                        autoClose: true,
                        multiple: false,
                        onAfterClose: function (fields) {
                            if (Gikam.isNotEmpty(fields)) {
                                // 获取固定列的数量：
                                var ids = fields.map(function (item) {
                                    return item.id;
                                }).join(",")
                                workspace.window.showMask();
                                var url = Gikam.printf(IFM_CONTEXT + '/core/module/item/files/{id}/action/import/' + 'LimsEquipmentImportFileFunction', {
                                    id: fields[0].id
                                }) + Gikam.param({
                                    ids: ids,
                                })
                                Gikam.post(url).done(function (req) {
                                    Gikam.getComp(_this.idManager.equipGrid).refresh()
                                    if (req.message){
                                        Gikam.alert(req.message)
                                    }
                                    if (req.url){
                                        Gikam.download(req.url);
                                    }
                                }).always(function () {
                                    workspace.window.closeMask()
                                })
                            }
                        }
                    })
                }
            }, {
                type: 'button',
                text: 'GIKAM.BUTTON.EXPORT_TEMPLATE',
                icon: 'export',
                onClick: function () {
                    Gikam.getText(IFM_CONTEXT + '/core/module/item/files/template-urls' + Gikam.param({
                        templateCode: 'LimsEquipmentExportTemplate',
                        service: 'LimsEquipmentExportTemplate',
                        id: '-'
                    })).done(function (url) {
                        Gikam.download(url)
                    })
                }
            }, {
                type: 'button',
                text: 'T_EQUIPMENT.BUTTON.CHANGE.EQUIPSTATE',
                icon: 'label-print',
                onClick: function () {
                    var mainGrid = Gikam.getComp(_this.idManager.equipGrid)
                    var selections = mainGrid.getSelections()
                    if (Gikam.isEmpty(selections)) {
                        Gikam.alert('GIKAM.TIP.CHOOSE_AT_LEAST_ONE_ITEM')
                        return
                    }
                    var model = Gikam.create('modal', {
                        title: 'GIKAM.CHEM.BUTTON.SAVE',
                        height: '300',
                        width: '400',
                    });
                    Gikam.create('layout', {
                        renderTo: model.window.$dom,
                        center: {
                            items: [{
                                type: 'form',
                                id: 'insert-equipstate-form',
                                fields: [{
                                    field: 'equipState',
                                    title: 'T_LIMS_EQUIPMENT.EQUIPSTATE',
                                    type: 'select',
                                    search: true,
                                    category: 'sys',
                                    firstBlank: false,
                                    param: {
                                        codeCategoryId: 'equipState'
                                    },
                                    validators: ['notEmpty']
                                }, {
                                    field: 'operationTime',
                                    title: 'T_LIMS_OPERATIONRECORD.CREATEDTIME',
                                    validators: ['notEmpty'],
                                    type: 'dateTime'
                                }, {
                                    field: 'remark',
                                    title: 'T_CORE_ACT_CONFIG.REMARK',
                                    type: 'textarea',
                                    colspan: 2
                                }],
                                onLoadSuccess: function () {
                                },
                                columns: 1,
                                titleWidth: 80
                            }, {
                                type: 'btnToolbar',
                                items: [{
                                    type: 'button',
                                    text: 'GIKAM.BUTTON.CONFIRM',
                                    class: 'blue',
                                    icon: 'save',
                                    color: 'white',
                                    onClick: function () {
                                        var form = Gikam.getComp('insert-equipstate-form')
                                        if (form.validate()) {
                                            workspace.window.showMask()
                                            var formData = form.getData()

                                            var updateEquipStateUrl = limsEquipment.baseUrl + '/update-equipstate'
                                            var data = {
                                                equipState: formData.equipState,
                                                remark: formData.remark,
                                                operationTime: formData.operationTime
                                            }
                                            Gikam.postText(updateEquipStateUrl, Gikam.getJsonWrapper(data, [null, selections])).done(function (req) {
                                                Gikam.alert('CORE.MODULE.TOPOLOGY.MODAL.TIP.TOPOLOGY_DESIGN_SAVED')
                                                mainGrid.refresh()
                                            }).always(function () {
                                                workspace.window.closeMask()
                                            })
                                            Gikam.getLastModal().close(data)
                                        }
                                    }
                                }, {
                                    type: 'button',
                                    text: 'GIKAM.BUTTON.CANCEL',
                                    icon: 'back',
                                    onClick: function () {
                                        Gikam.getLastModal().close();
                                    }
                                }]
                            }]
                        }
                    })
                }
            }]
        }
    },

    loadDetailPage: function (row, readonly) {
        workspace.window.load(limsEquipment.baseUrl + '/page/detail-page' + Gikam.param({
            id: row.id,
        }))
    },

    refreshTabs: function (row) {
        let _this = this
        //详情form
        Gikam.getAsyncComp(_this.idManager.equipForm).done(function (form) {
            if (row && row.id) {
                form.setReadonly(false)
                form.toFieldsReadonly(['equipCode', 'equipState'])
                form.refresh({
                    url: Gikam.printf(limsEquipment.baseUrl + '/{id}', {
                        id: row.id
                    })
                })
            } else {
                form.setReadonly(true)
                form.refresh({
                    url: Gikam.printf(limsEquipment.baseUrl + '/{id}', {
                        id: -1
                    })
                })
            }
        })
        // 配件记录
        Gikam.getAsyncComp(_this.idManager.equipAccessoriesGrid).done(grid => {
            if (row && row.id) {
                grid.refresh({
                    url: _this.urlManager.equipAccessoriesGrid + '/queries',
                    requestData: {
                        equipmentId_EQ: row.id
                    }
                })
            } else {
                grid.refresh({
                    url: _this.urlManager.equipAccessoriesGrid + '/queries',
                    requestData: {
                        equipmentId_EQ: -1
                    }
                })
            }
        })
        // 验收确认记录
        Gikam.getAsyncComp(_this.idManager.equipAcceptanceGrid).done(grid => {
            if (row && row.id) {
                grid.refresh({
                    url: _this.urlManager.equipAcceptanceGrid + '/queries',
                    requestData: {
                        equipmentId_EQ: row.id
                    }
                })
            } else {
                grid.refresh({
                    url: _this.urlManager.equipAcceptanceGrid + '/queries',
                    requestData: {
                        equipmentId_EQ: -1
                    }
                })
            }
        })
        // 故障维修记录
        Gikam.getAsyncComp(_this.idManager.equipNewMaintainGrid).done(grid => {
            if (row && row.id) {
                grid.refresh({
                    url: _this.urlManager.equipNewMaintainGrid + '/queries',
                    requestData: {
                        equipmentId_EQ: row.id
                    }
                })
            } else {
                grid.refresh({
                    url: _this.urlManager.equipNewMaintainGrid + '/queries',
                    requestData: {
                        equipmentId_EQ: -1
                    }
                })
            }
        })
        // 计量记录
        Gikam.getAsyncComp(_this.idManager.equipMeasureGrid).done(grid => {
            if (row && row.id) {
                grid.refresh({
                    url: _this.urlManager.equipMeasureGrid + '/queries',
                    requestData: {
                        equipmentId_EQ: row.id
                    }
                })
            } else {
                grid.refresh({
                    url: _this.urlManager.equipMeasureGrid + '/queries',
                    requestData: {
                        equipmentId_EQ: -1
                    }
                })
            }
        })
        // 维保记录
        Gikam.getAsyncComp(_this.idManager.equipMaintainGrid).done(grid => {
            if (row && row.id) {
                grid.refresh({
                    url: _this.urlManager.equipMaintainGrid + '/queries',
                    requestData: {
                        equipmentId_EQ: row.id
                    }
                })
            } else {
                grid.refresh({
                    url: _this.urlManager.equipMaintainGrid + '/queries',
                    requestData: {
                        equipmentId_EQ: -1
                    }
                })
            }
        })
        // 验证记录
        Gikam.getAsyncComp(_this.idManager.equipVerificationRecordGrid).done(grid => {
            if (row && row.id) {
                grid.refresh({
                    url: _this.urlManager.equipVerificationRecordGrid + '/queries',
                    requestData: {
                        equipmentId_EQ: row.id
                    }
                })
            } else {
                grid.refresh({
                    url: _this.urlManager.equipVerificationRecordGrid + '/queries',
                    requestData: {
                        equipmentId_EQ: -1
                    }
                })
            }
        })
        // 状态修改记录
        Gikam.getAsyncComp(_this.idManager.operationRecord).done(grid => {
            if (row && row.id) {
                grid.refresh({
                    url: _this.urlManager.operationRecord + '/queries',
                    requestData: {
                        businessId_EQ: row.id
                    }
                })
            } else {
                grid.refresh({
                    url: _this.urlManager.operationRecord + '/queries',
                    requestData: {
                        businessId_EQ: row.id
                    }
                })
            }
        })
        // 附件
        _this.refreshAttachments(_this.idManager.equipGrid)
    },

    getBaseInfoTab: function () {
        var _this = this
        return {
            type: 'tab',
            panels: [{
                title: 'BASEMODULE.RM.EQUIPMENTS.TAB.BASE_INFO',
                items: [{
                    type: 'form',
                    service: 'limsEquipmentServiceImpl',
                    dbTable: 'T_LIMS_EQUIPMENT',
                    id: _this.idManager.equipForm,
                    fields: limsEquipment.getBaseInfoFormFields(),
                    onUpdated: function () {
                        var grid = Gikam.getComp(_this.idManager.equipGrid)
                        grid.refreshRowById(grid.getActivedRow().id)
                    },
                }]
            }, {// 配件记录
                title: 'T_LIMS_EQUIPMENT_ACCESSORIES.SERVICE_NAME',
                items: [{
                    type: 'grid',
                    id: _this.idManager.equipAccessoriesGrid,
                    height: 300,
                    columns: limsEquipment.getAccessoriesEditListColumns(),
                    service: 'limsEquipmentAccessoriesServiceImpl',
                    onLoadSuccess: function (rows) {
                        if (Gikam.isNotEmpty(rows)) {
                            this.activeRowByIndex(0)
                        } else {
                            _this.refreshAttachments(_this.idManager.equipAccessoriesGrid)
                        }
                    },
                    onRowActive: function (index, row) {
                        _this.refreshAttachments(_this.idManager.equipAccessoriesGrid)
                    },
                    deleteFormatter: function (row) {
                        return row.name
                    },
                    toolbar: [{
                        type: 'button',
                        text: 'GIKAM.BUTTON.INSERT',
                        icon: 'add',
                        onClick: function () {
                            let equipGrid = Gikam.getComp(_this.idManager.equipGrid)
                            let actRow = equipGrid.getActivedRow()
                            if (Gikam.isEmpty(actRow)) {
                                Gikam.alert('GIKAM.TIP.CHOOSE_AT_LEAST_ONE_ITEM')
                                return
                            }
                            Gikam.preInsert({
                                modalTitle: 'BASEMODULE.RM.EQUIPMENTS.MODAL.ADD',
                                fields: limsEquipment.getAccessoriesBaseInfoFormFields(),
                                disableNotEmptyValidate: true,
                                url: _this.urlManager.equipAccessoriesGrid,
                                param: {
                                    equipmentId: actRow.id
                                }
                            }).done(function (id) {
                                Gikam.getComp(_this.idManager.equipAccessoriesGrid).refresh()
                            })
                        }
                    }, {
                        type: 'button',
                        text: 'GIKAM.BUTTON.DELETE',
                        icon: 'remove',
                        onClick: function () {
                            Gikam.getComp(_this.idManager.equipAccessoriesGrid).deleteRows(_this.urlManager.equipAccessoriesGrid)
                        }
                    }]
                }, _this.getAttachmantStruct(_this.idManager.equipAccessoriesGrid, 'T_LIMS_EQUIPMENT_ACCESSORIES')]
            }, {// 验收确认记录
                title: 'T_LIMS_EQUIPMENT_ACCEPTANCE.SERVICE_NAME',
                items: [{
                    type: 'grid',
                    id: _this.idManager.equipAcceptanceGrid,
                    height: 300,
                    columns: limsEquipment.getAcceptanceEditListColumns(),
                    service: 'limsEquipmentAcceptanceServiceImpl',
                    onLoadSuccess: function (rows) {
                        if (Gikam.isNotEmpty(rows)) {
                            this.activeRowByIndex(0)
                        } else {
                            _this.refreshAttachments(_this.idManager.equipAcceptanceGrid)
                        }
                    },
                    onRowActive: function (index, row) {
                        _this.refreshAttachments(_this.idManager.equipAcceptanceGrid)
                    },
                    deleteFormatter: function (row) {
                        return row.cause
                    },
                    toolbar: [{
                        type: 'button',
                        text: 'GIKAM.BUTTON.INSERT',
                        icon: 'add',
                        onClick: function () {
                            let equipGrid = Gikam.getComp(_this.idManager.equipGrid)
                            let actRow = equipGrid.getActivedRow()
                            if (Gikam.isEmpty(actRow)) {
                                Gikam.alert('GIKAM.TIP.CHOOSE_AT_LEAST_ONE_ITEM')
                                return
                            }
                            Gikam.preInsert({
                                modalTitle: 'BASEMODULE.RM.EQUIPMENTS.MODAL.ADD',
                                fields: limsEquipment.getAcceptanceBaseInfoFormFields(),
                                disableNotEmptyValidate: true,
                                url: _this.urlManager.equipAcceptanceGrid,
                                param: {
                                    equipmentId: actRow.id
                                }
                            }).done(function (id) {
                                Gikam.getComp(_this.idManager.equipAcceptanceGrid).refresh()
                            })
                        }
                    }, {
                        type: 'button',
                        text: 'GIKAM.BUTTON.DELETE',
                        icon: 'remove',
                        onClick: function () {
                            Gikam.getComp(_this.idManager.equipAcceptanceGrid).deleteRows(_this.urlManager.equipAcceptanceGrid)
                        }
                    }]
                }, _this.getAttachmantStruct(_this.idManager.equipAcceptanceGrid, 'T_LIMS_EQUIPMENT_ACCEPTANCE')]
            }, {
                title: 'T_LIMS_EQUIPMENT_NEWMAINTAIN.SERVICE_NAME',
                items: [{
                    type: 'grid',
                    id: _this.idManager.equipNewMaintainGrid,
                    height: 300,
                    columns: limsEquipment.getNewMaintainEditListColumns(),
                    service: 'limsEquipmentNewmaintainServiceImpl',
                    onLoadSuccess: function (rows) {
                        if (Gikam.isNotEmpty(rows)) {
                            this.activeRowByIndex(0)
                        } else {
                            _this.refreshAttachments(_this.idManager.equipNewMaintainGrid)
                        }
                    },
                    onRowActive: function (index, row) {
                        _this.refreshAttachments(_this.idManager.equipNewMaintainGrid)
                    },
                    deleteFormatter: function (row) {
                        return row.cause
                    },
                    toolbar: [{
                        type: 'button',
                        text: 'GIKAM.BUTTON.INSERT',
                        icon: 'add',
                        onClick: function () {
                            let equipGrid = Gikam.getComp(_this.idManager.equipGrid)
                            let actRow = equipGrid.getActivedRow()
                            if (Gikam.isEmpty(actRow)) {
                                Gikam.alert('GIKAM.TIP.CHOOSE_AT_LEAST_ONE_ITEM')
                                return
                            }
                            Gikam.preInsert({
                                modalTitle: 'BASEMODULE.RM.EQUIPMENTS.MODAL.ADD',
                                fields: limsEquipment.getNewMaintainBaseInfoFormFields(),
                                disableNotEmptyValidate: true,
                                url: _this.urlManager.equipNewMaintainGrid,
                                param: {
                                    equipmentId: actRow.id
                                }
                            }).done(function (id) {
                                Gikam.getComp(_this.idManager.equipNewMaintainGrid).refresh()
                            })
                        }
                    }, {
                        type: 'button',
                        text: 'GIKAM.BUTTON.DELETE',
                        icon: 'remove',
                        onClick: function () {
                            var selections = Gikam.getComp(_this.idManager.equipNewMaintainGrid).getSelections()
                            for (let i = 0; i < selections.length; i++) {
                                if (selections[i].status === 'done') {
                                    Gikam.alert("EXISTS.COMPLATED.RECORD.PLEASE.CHOOSE.AGAIN")
                                    return false
                                }
                            }
                            Gikam.getComp(_this.idManager.equipNewMaintainGrid).deleteRows(_this.urlManager.equipNewMaintainGrid)
                        }
                    }]
                }, _this.getAttachmantStruct(_this.idManager.equipNewMaintainGrid, 'T_LIMS_EQUIPMENT_NEWMAINTAIN')]
            }, {
                title: 'T_LIMS_EQUIPMENT_MEASURE.SERVICE_NAME',// 计量记录
                items: [{
                    type: 'grid',
                    id: _this.idManager.equipMeasureGrid,
                    height: 300,
                    columns: limsEquipment.getMeasureEditListColumns(),
                    service: 'limsEquipmentMeasureServiceImpl',
                    onLoadSuccess: function (rows) {
                        if (Gikam.isNotEmpty(rows)) {
                            this.activeRowByIndex(0)
                        } else {
                            _this.refreshAttachments(_this.idManager.equipMeasureGrid)
                        }
                    },
                    onRowActive: function (index, row) {
                        _this.refreshAttachments(_this.idManager.equipMeasureGrid)
                    },
                    deleteFormatter: function (row) {
                        return row.cycle
                    },
                    toolbar: [{
                        type: 'button',
                        text: 'GIKAM.BUTTON.INSERT',
                        icon: 'add',
                        onClick: function () {
                            let equipGrid = Gikam.getComp(_this.idManager.equipGrid)
                            let actRow = equipGrid.getActivedRow()
                            if (Gikam.isEmpty(actRow)) {
                                Gikam.alert('GIKAM.TIP.CHOOSE_AT_LEAST_ONE_ITEM')
                                return
                            }
                            Gikam.preInsert({
                                modalTitle: 'BASEMODULE.RM.EQUIPMENTS.MODAL.ADD',
                                fields: limsEquipment.getMeasureBaseInfoFormFields(),
                                disableNotEmptyValidate: true,
                                url: _this.urlManager.equipMeasureGrid,
                                param: {
                                    equipmentId: actRow.id
                                }
                            }).done(function (id) {
                                Gikam.getComp(_this.idManager.equipMeasureGrid).refresh()
                            })
                        }
                    }, {
                        type: 'button',
                        text: 'GIKAM.BUTTON.DELETE',
                        icon: 'remove',
                        onClick: function () {
                            var selections = Gikam.getComp(_this.idManager.equipMeasureGrid).getSelections()
                            for (let i = 0; i < selections.length; i++) {
                                if (selections[i].measureStatus === 'done') {
                                    Gikam.alert("EXISTS.COMPLATED.RECORD.PLEASE.CHOOSE.AGAIN")
                                    return false
                                }
                            }
                            Gikam.getComp(_this.idManager.equipMeasureGrid).deleteRows(_this.urlManager.equipMeasureGrid)
                        }
                    }]
                }, _this.getAttachmantStruct(_this.idManager.equipMeasureGrid, 'T_LIMS_EQUIPMENT_MEASURE')]
            }, {
                title: 'T_LIMS_EQUIPMENT_MAINTAIN.SERVICE_NAME',// 维保记录
                items: [{
                    type: 'grid',
                    id: _this.idManager.equipMaintainGrid,
                    height: 300,
                    columns: limsEquipment.getMaintainEditListColumns(),
                    service: 'limsEquipmentMaintainServiceImpl',
                    onLoadSuccess: function (rows) {
                        if (Gikam.isNotEmpty(rows)) {
                            this.activeRowByIndex(0)
                        } else {
                            _this.refreshAttachments(_this.idManager.equipMaintainGrid)
                        }
                    },
                    onRowActive: function (index, row) {
                        _this.refreshAttachments(_this.idManager.equipMaintainGrid)
                    },
                    deleteFormatter: function (row) {
                        return row.maintainCycle
                    },
                    toolbar: [{
                        type: 'button',
                        text: 'GIKAM.BUTTON.INSERT',
                        icon: 'add',
                        onClick: function () {
                            let equipGrid = Gikam.getComp(_this.idManager.equipGrid)
                            let actRow = equipGrid.getActivedRow()
                            if (Gikam.isEmpty(actRow)) {
                                Gikam.alert('GIKAM.TIP.CHOOSE_AT_LEAST_ONE_ITEM')
                                return
                            }
                            Gikam.preInsert({
                                modalTitle: 'BASEMODULE.RM.EQUIPMENTS.MODAL.ADD',
                                fields: limsEquipment.getMaintainBaseInfoFormFields(),
                                disableNotEmptyValidate: true,
                                url: _this.urlManager.equipMaintainGrid,
                                param: {
                                    equipmentId: actRow.id
                                }
                            }).done(function (id) {
                                Gikam.getComp(_this.idManager.equipMaintainGrid).refresh()
                            })
                        }
                    }, {
                        type: 'button',
                        text: 'GIKAM.BUTTON.DELETE',
                        icon: 'remove',
                        onClick: function () {
                            var selections = Gikam.getComp(_this.idManager.equipMaintainGrid).getSelections()
                            for (let i = 0; i < selections.length; i++) {
                                if (selections[i].status === 'done') {
                                    Gikam.alert("EXISTS.COMPLATED.RECORD.PLEASE.CHOOSE.AGAIN")
                                    return false
                                }
                            }
                            Gikam.getComp(_this.idManager.equipMaintainGrid).deleteRows(_this.urlManager.equipMaintainGrid)
                        }
                    }]
                }, _this.getAttachmantStruct(_this.idManager.equipMaintainGrid, 'T_LIMS_EQUIPMENT_MAINTAIN')]
            }, {
                title: 'T_LIMS_EQUIP_VERIFICATION_RECORD.SERVICE_NAME',
                items: [{
                    type: 'grid',
                    id: _this.idManager.equipVerificationRecordGrid,
                    service: 'limsEquipVerificationRecordServiceImpl',
                    dbTable: 'T_LIMS_EQUIP_VERIFICATION_RECORD',
                    columns: limsEquipment.getVerificationRecordEditListColumns(),
                    deleteFormatter: function (row) {
                        return row.verificationType + '-' + row.verificationDetail
                    },
                    onLoadSuccess: function (data) {
                        if (!Gikam.isEmpty(data)) {
                            this.activeRowByIndex(0)
                        } else {
                            _this.refreshAttachments(_this.idManager.equipVerificationRecordGrid)
                        }
                    },
                    onRowActive: function (index, row) {
                        _this.refreshAttachments(_this.idManager.equipVerificationRecordGrid)
                    },
                    height: 300,
                    toolbar: [{
                        type: 'button',
                        text: 'GIKAM.BUTTON.INSERT',
                        icon: 'add',
                        onClick: function () {
                            let equipGrid = Gikam.getComp(_this.idManager.equipGrid)
                            let actRow = equipGrid.getActivedRow()
                            if (Gikam.isEmpty(actRow)) {
                                Gikam.alert('GIKAM.TIP.CHOOSE_AT_LEAST_ONE_ITEM')
                                return
                            }
                            Gikam.preInsert({
                                modalTitle: 'BASEMODULE.RM.EQUIPMENTS.MODAL.ADD',
                                fields: limsEquipment.getVerificationRecordBaseInfoFormFields(),
                                url: _this.urlManager.equipVerificationRecordGrid,
                                param: {
                                    equipmentId: actRow.id
                                }
                            }).done(function (req) {
                                Gikam.getComp('lims-equip-verification-record-edit-list-grid').refresh()
                            })
                        }
                    }, {
                        type: 'button',
                        text: 'GIKAM.BUTTON.DELETE',
                        icon: 'remove-row',
                        onClick: function () {
                            Gikam.getComp('lims-equip-verification-record-edit-list-grid').deleteRows(_this.urlManager.equipVerificationRecordGrid)
                        }
                    }]
                }, _this.getAttachmantStruct(_this.idManager.equipVerificationRecordGrid, 'T_LIMS_EQUIP_VERIFICATION_RECORD')]
            }, {
                title: 'T_EQUIPMENT.TABLENAME.CHANGE.EQUIPSTATE',
                items: [{
                    type: 'grid',
                    id: _this.idManager.operationRecord,
                    service: 'limsOperationrecordServiceImpl',
                    dbTable: 'T_LIMS_OPERATIONRECORD',
                    columns: limsEquipment.getOperationRecordListColumns(),
                    onLoadSuccess: function (data) {
                    },
                    onRowActive: function (index, row) {
                    },
                    toolbar: [],
                    order: {'operationTime': 'asc'},
                }]
            }, {
                title: 'GIKAM.FILE.ATTACHMENT',
                items: [_this.getAttachmantStruct(_this.idManager.equipGrid, 'T_LIMS_EQUIPMENT')]
            },]
        }
    },

    getAttachUploaderId: function (gridId) {
        return gridId + '-uploader'
    },

    refreshAttachments: function (gridId) {
        let _this = this
        let grid = Gikam.getComp(gridId)
        let actRow = grid.getActivedRow()
        Gikam.getAsyncComp(_this.getAttachUploaderId(gridId)).done(uploader => {
            if (actRow && actRow.id) {
                uploader.setOptions({
                    bizId: actRow.id,
                })
            } else {
                uploader.setOptions({
                    bizId: -1,
                })
            }
        })
    },

    getAttachmantStruct: function (gridId, dbTable) {
        let _this = this
        return {
            type: 'uploader',
            immediateUpload: true,
            id: _this.getAttachUploaderId(gridId),
            dbTable: dbTable,
            // bizId: -1,
            filter: false,
            genericQuery: false,
            onBeforeUpload: function () {
                var activedRow = Gikam.getComp(gridId).getActivedRow()
                if (Gikam.isEmpty(activedRow)) {
                    Gikam.alert('GIKAM.TIP.CHOOSE_AT_LEAST_ONE_ITEM', 200)
                    return false
                }
            },
        }
    },

    create: function () {
        var _this = this
        Gikam.create('layout', {
            id: 'lims-equipment-edit-list-layout',
            renderTo: workspace.window.$dom,
            center: {
                items: [this.getGridParam()]
            }
        })
    },

    idManager: {
        equipGrid: 'lims-equipment-edit-list-grid',
        equipForm: 'lims-equipment-edit-list-base-info-form',
        equipVerificationRecordGrid: 'lims-equip-verification-record-edit-list-grid',
        equipMaintainGrid: 'lims-equipment-maintain-edit-list-grid',
        equipMeasureGrid: 'lims-equipment-measure-edit-list-grid',
        equipNewMaintainGrid: 'lims-equipment-newmaintain-edit-list-grid',
        equipAcceptanceGrid: 'lims-equipment-acceptance-edit-list-grid',
        equipAccessoriesGrid: 'lims-equipment-accessories-edit-list-grid',
        operationRecord: IFM_CONTEXT + 'lims-equipment-operation-record-list-grid',
    },

    urlManager: {
        equipVerificationRecordGrid: IFM_CONTEXT + '/secure/basemodule/rm/equip-verification-records',
        equipMaintainGrid: IFM_CONTEXT + '/secure/basemodule/rm/equipment-maintains',
        equipMeasureGrid: IFM_CONTEXT + '/secure/basemodule/rm/equipment-measures',
        equipNewMaintainGrid: IFM_CONTEXT + '/secure/basemodule/rm/equipment-newmaintains',
        equipAcceptanceGrid: IFM_CONTEXT + '/secure/basemodule/rm/equipment-acceptances',
        equipAccessoriesGrid: IFM_CONTEXT + '/secure/basemodule/rm/equipment-accessoriess',
        operationRecord: IFM_CONTEXT + '/secure/basemodule/basedata/operationrecords',
    },

    init: function () {
        this.create()
    }
}
